using System;
using System.Collections.Generic;
using System.Text;

namespace Abp.Extension.CodeGenerater
{
    public static class SystemRule
    {
        public static string SetTab(int iPos)
        {
            StringBuilder stbSpace = new StringBuilder();
            for (int i = 0; i < iPos; i++)
            {
                stbSpace.Append(" ");
            }
            return stbSpace.ToString();
        }

        public static string ConvertOracleType(string strtype)
        {
            string strReturn="";
            int iPos = -1;
            int iPos2=-1;
            string strShort = strtype.Substring(0, 3).ToLower();
            if (strShort == "var" || strShort == "cha")
            {
                strReturn="OracleType.VarChar," ;
                iPos = strtype.IndexOf("(");
                if (iPos == -1)
                {
                    return strReturn + "0";
                }

                return strReturn + strtype.Substring(iPos +1,strtype.Length - iPos -2);
            }
            if (strShort == "dat")
            {
                strReturn = "OracleType.DateTime,7";
            }
            if (strShort == "num")
            { 
                iPos = strtype.IndexOf("(");
                if (iPos == -1)
                {
                    strReturn = "OracleType.Number,38";
                    return strReturn;
                }
                iPos2 = strtype.IndexOf(",");
                strReturn = "OracleType.Number,";
                if (iPos2 == -1)
                {
                    return strReturn + strtype.Substring(iPos + 1, strtype.Length - iPos - 2);
                }
                return strReturn + strtype.Substring(iPos + 1, iPos2 - iPos -1 );

            }
            return "";
        }
    }
}
